package cn.ibizlab.odoo.core.odoo_hr.service.impl;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.HashMap;
import java.math.BigInteger;
import java.util.Collection;

import lombok.extern.slf4j.Slf4j;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cglib.beans.BeanCopier;
import org.springframework.stereotype.Service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import cn.ibizlab.odoo.core.client.model.Ihr_employee;
import cn.ibizlab.odoo.core.odoo_hr.domain.Hr_employee;
import cn.ibizlab.odoo.core.odoo_hr.filter.Hr_employeeSearchContext;
import cn.ibizlab.odoo.core.odoo_hr.service.IHr_employeeService;
import cn.ibizlab.odoo.util.SearchResult;
import cn.ibizlab.odoo.util.log.IBIZLog;

/**
 * 实体[员工] 服务对象接口实现
 */
@Slf4j
@IBIZLog
@Service
public class Hr_employeeServiceImpl implements IHr_employeeService {

    @Autowired
    private cn.ibizlab.odoo.core.client.service.Ihr_employeeClientService hr_employeeClientService;

    @Override
    public boolean create(Hr_employee hr_employee) {
        boolean bOk = false ;
        Ihr_employee clientModel = this.convert2Model(hr_employee,null);
        hr_employeeClientService.create(clientModel) ;
        this.convert2Domain(clientModel,hr_employee);
        bOk = true ;

        return bOk ;
    }

    @Override
    public boolean remove(Integer id) {
        boolean bOk = false ;
        Ihr_employee clientModel = hr_employeeClientService.createModel();
        clientModel.setId(id);
        hr_employeeClientService.remove(clientModel) ;
        bOk = true ;
        return bOk ;
    }

    @Override
    public boolean update(Hr_employee hr_employee) {
        boolean bOk = false ;
        Ihr_employee clientModel = this.convert2Model(hr_employee,null);
        hr_employeeClientService.update(clientModel) ;
        this.convert2Domain(clientModel,hr_employee) ;
        bOk = true;
        return bOk ;
    }

    @Override
    public void updateBatch(List<Hr_employee> hr_employees, int batchSize) {

        //hr_employeeClientService.updateBatch(hr_employees,batchSize) ;

    }

    @Override
    public Hr_employee get(Integer id) {
        Ihr_employee clientModel = hr_employeeClientService.createModel();
        clientModel.setId(id);
        hr_employeeClientService.get(clientModel) ;
        return this.convert2Domain(clientModel,null);
    }

    @Override
    public Hr_employee get(Hr_employee hr_employee) {
        Hr_employee rethr_employee = this.get(hr_employee.getId()) ;
    	BeanCopier copier=BeanCopier.create(rethr_employee.getClass(), hr_employee.getClass(), false);
        copier.copy(rethr_employee, hr_employee, null);
        return hr_employee ;
    }

    @Override
    public void removeBatch(Collection<? extends Serializable> idList, int batchSize) {

        //hr_employeeClientService.removeBatch(hr_employees) ;

    }

    @Override
    public void createBatch(List<Hr_employee> hr_employees, int batchSize) {

                        //hr_employeeClientService.createBatch(hr_employees,batchSize) ;

    }

    /**
     * 查询集合 默认查询
     */
    @Override
    public Page<Hr_employee> searchDefault(Hr_employeeSearchContext context) {
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());
    }


    /**
     * 根据出勤查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_last_attendance(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据HR 部门查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_department(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据员工查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_coach(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据员工查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_parent(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据工作岗位查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_job(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据资源工作时间查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_resource_calendar(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据资源查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_resource(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据公司查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_company(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据国家/地区查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_country(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据国家/地区查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_country_of(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据银行账户查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_bank_account(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据联系人查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_address_home(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据联系人查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_address(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_create(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_expense_manager(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_user(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }

    /**
     * 根据用户查询
     */
    @Override
    public Page<Hr_employee> selectByOdoo_write(Integer id){
        Hr_employeeSearchContext context = new Hr_employeeSearchContext();
        if(!org.springframework.util.StringUtils.isEmpty(id)){
            cn.ibizlab.odoo.util.SearchFieldFilter fieldFilter=new cn.ibizlab.odoo.util.SearchFieldFilter();
            fieldFilter.setParam("id");
            fieldFilter.setCondition(cn.ibizlab.odoo.util.enums.SearchFieldType.EQ);
            fieldFilter.setValue(id);
            context.getCondition().add(fieldFilter);
        }
        List<Hr_employee> list = new ArrayList<Hr_employee>();
        Page<cn.ibizlab.odoo.core.client.model.Ihr_employee> clientModelList = hr_employeeClientService.search(context) ;
        for(cn.ibizlab.odoo.core.client.model.Ihr_employee clientModel : clientModelList){
            list.add( this.convert2Domain(clientModel,null));
        }
        return new PageImpl<Hr_employee>(list, context.getPageable(), clientModelList.getTotalElements());

    }



    public Ihr_employee convert2Model(Hr_employee domain , Ihr_employee model) {
        if(domain == null)
            return model ;
        if(model==null){
            model = hr_employeeClientService.createModel() ;
        }

         if(domain.getMobile_phoneDirtyFlag())
            model.setMobile_phone(domain.getMobile_phone());
         if(domain.getMessage_has_error_counterDirtyFlag())
            model.setMessage_has_error_counter(domain.getMessage_has_error_counter());
         if(domain.getMessage_needaction_counterDirtyFlag())
            model.setMessage_needaction_counter(domain.getMessage_needaction_counter());
         if(domain.getLeave_date_fromDirtyFlag())
            model.setLeave_date_from(domain.getLeave_date_from());
         if(domain.getMessage_unreadDirtyFlag())
            model.setMessage_unread(domain.getMessage_unread());
         if(domain.getChildrenDirtyFlag())
            model.setChildren(domain.getChildren());
         if(domain.getImage_smallDirtyFlag())
            model.setImage_small(domain.getImage_small());
         if(domain.getMessage_needactionDirtyFlag())
            model.setMessage_needaction(domain.getMessage_needaction());
         if(domain.getPinDirtyFlag())
            model.setPin(domain.getPin());
         if(domain.getMessage_main_attachment_idDirtyFlag())
            model.setMessage_main_attachment_id(domain.getMessage_main_attachment_id());
         if(domain.getStudy_schoolDirtyFlag())
            model.setStudy_school(domain.getStudy_school());
         if(domain.getActivity_idsDirtyFlag())
            model.setActivity_ids(domain.getActivity_ids());
         if(domain.getMaritalDirtyFlag())
            model.setMarital(domain.getMarital());
         if(domain.getDirect_badge_idsDirtyFlag())
            model.setDirect_badge_ids(domain.getDirect_badge_ids());
         if(domain.getImage_mediumDirtyFlag())
            model.setImage_medium(domain.getImage_medium());
         if(domain.get__last_updateDirtyFlag())
            model.set__last_update(domain.get__last_update());
         if(domain.getEmergency_phoneDirtyFlag())
            model.setEmergency_phone(domain.getEmergency_phone());
         if(domain.getActivity_date_deadlineDirtyFlag())
            model.setActivity_date_deadline(domain.getActivity_date_deadline());
         if(domain.getKm_home_workDirtyFlag())
            model.setKm_home_work(domain.getKm_home_work());
         if(domain.getVisa_noDirtyFlag())
            model.setVisa_no(domain.getVisa_no());
         if(domain.getPlace_of_birthDirtyFlag())
            model.setPlace_of_birth(domain.getPlace_of_birth());
         if(domain.getSpouse_complete_nameDirtyFlag())
            model.setSpouse_complete_name(domain.getSpouse_complete_name());
         if(domain.getSinidDirtyFlag())
            model.setSinid(domain.getSinid());
         if(domain.getBadge_idsDirtyFlag())
            model.setBadge_ids(domain.getBadge_ids());
         if(domain.getWork_emailDirtyFlag())
            model.setWork_email(domain.getWork_email());
         if(domain.getHas_badgesDirtyFlag())
            model.setHas_badges(domain.getHas_badges());
         if(domain.getCurrent_leave_idDirtyFlag())
            model.setCurrent_leave_id(domain.getCurrent_leave_id());
         if(domain.getContract_idsDirtyFlag())
            model.setContract_ids(domain.getContract_ids());
         if(domain.getMessage_is_followerDirtyFlag())
            model.setMessage_is_follower(domain.getMessage_is_follower());
         if(domain.getMessage_channel_idsDirtyFlag())
            model.setMessage_channel_ids(domain.getMessage_channel_ids());
         if(domain.getBarcodeDirtyFlag())
            model.setBarcode(domain.getBarcode());
         if(domain.getBirthdayDirtyFlag())
            model.setBirthday(domain.getBirthday());
         if(domain.getCertificateDirtyFlag())
            model.setCertificate(domain.getCertificate());
         if(domain.getActivity_user_idDirtyFlag())
            model.setActivity_user_id(domain.getActivity_user_id());
         if(domain.getStudy_fieldDirtyFlag())
            model.setStudy_field(domain.getStudy_field());
         if(domain.getWebsite_message_idsDirtyFlag())
            model.setWebsite_message_ids(domain.getWebsite_message_ids());
         if(domain.getActivity_summaryDirtyFlag())
            model.setActivity_summary(domain.getActivity_summary());
         if(domain.getAttendance_stateDirtyFlag())
            model.setAttendance_state(domain.getAttendance_state());
         if(domain.getContracts_countDirtyFlag())
            model.setContracts_count(domain.getContracts_count());
         if(domain.getGenderDirtyFlag())
            model.setGender(domain.getGender());
         if(domain.getImageDirtyFlag())
            model.setImage(domain.getImage());
         if(domain.getSpouse_birthdateDirtyFlag())
            model.setSpouse_birthdate(domain.getSpouse_birthdate());
         if(domain.getMessage_unread_counterDirtyFlag())
            model.setMessage_unread_counter(domain.getMessage_unread_counter());
         if(domain.getLeaves_countDirtyFlag())
            model.setLeaves_count(domain.getLeaves_count());
         if(domain.getNotesDirtyFlag())
            model.setNotes(domain.getNotes());
         if(domain.getAdditional_noteDirtyFlag())
            model.setAdditional_note(domain.getAdditional_note());
         if(domain.getWrite_dateDirtyFlag())
            model.setWrite_date(domain.getWrite_date());
         if(domain.getMedic_examDirtyFlag())
            model.setMedic_exam(domain.getMedic_exam());
         if(domain.getVisa_expireDirtyFlag())
            model.setVisa_expire(domain.getVisa_expire());
         if(domain.getWork_phoneDirtyFlag())
            model.setWork_phone(domain.getWork_phone());
         if(domain.getEmergency_contactDirtyFlag())
            model.setEmergency_contact(domain.getEmergency_contact());
         if(domain.getNewly_hired_employeeDirtyFlag())
            model.setNewly_hired_employee(domain.getNewly_hired_employee());
         if(domain.getDisplay_nameDirtyFlag())
            model.setDisplay_name(domain.getDisplay_name());
         if(domain.getIs_address_home_a_companyDirtyFlag())
            model.setIs_address_home_a_company(domain.getIs_address_home_a_company());
         if(domain.getAttendance_idsDirtyFlag())
            model.setAttendance_ids(domain.getAttendance_ids());
         if(domain.getActivity_stateDirtyFlag())
            model.setActivity_state(domain.getActivity_state());
         if(domain.getMessage_has_errorDirtyFlag())
            model.setMessage_has_error(domain.getMessage_has_error());
         if(domain.getCurrent_leave_stateDirtyFlag())
            model.setCurrent_leave_state(domain.getCurrent_leave_state());
         if(domain.getChild_idsDirtyFlag())
            model.setChild_ids(domain.getChild_ids());
         if(domain.getMessage_idsDirtyFlag())
            model.setMessage_ids(domain.getMessage_ids());
         if(domain.getColorDirtyFlag())
            model.setColor(domain.getColor());
         if(domain.getManual_attendanceDirtyFlag())
            model.setManual_attendance(domain.getManual_attendance());
         if(domain.getRemaining_leavesDirtyFlag())
            model.setRemaining_leaves(domain.getRemaining_leaves());
         if(domain.getSsnidDirtyFlag())
            model.setSsnid(domain.getSsnid());
         if(domain.getJob_titleDirtyFlag())
            model.setJob_title(domain.getJob_title());
         if(domain.getActivity_type_idDirtyFlag())
            model.setActivity_type_id(domain.getActivity_type_id());
         if(domain.getIs_absent_totayDirtyFlag())
            model.setIs_absent_totay(domain.getIs_absent_totay());
         if(domain.getMessage_partner_idsDirtyFlag())
            model.setMessage_partner_ids(domain.getMessage_partner_ids());
         if(domain.getPassport_idDirtyFlag())
            model.setPassport_id(domain.getPassport_id());
         if(domain.getGoal_idsDirtyFlag())
            model.setGoal_ids(domain.getGoal_ids());
         if(domain.getLeave_date_toDirtyFlag())
            model.setLeave_date_to(domain.getLeave_date_to());
         if(domain.getManagerDirtyFlag())
            model.setManager(domain.getManager());
         if(domain.getWork_locationDirtyFlag())
            model.setWork_location(domain.getWork_location());
         if(domain.getMessage_attachment_countDirtyFlag())
            model.setMessage_attachment_count(domain.getMessage_attachment_count());
         if(domain.getContract_idDirtyFlag())
            model.setContract_id(domain.getContract_id());
         if(domain.getGoogle_drive_linkDirtyFlag())
            model.setGoogle_drive_link(domain.getGoogle_drive_link());
         if(domain.getPermit_noDirtyFlag())
            model.setPermit_no(domain.getPermit_no());
         if(domain.getMessage_follower_idsDirtyFlag())
            model.setMessage_follower_ids(domain.getMessage_follower_ids());
         if(domain.getIdDirtyFlag())
            model.setId(domain.getId());
         if(domain.getIdentification_idDirtyFlag())
            model.setIdentification_id(domain.getIdentification_id());
         if(domain.getVehicleDirtyFlag())
            model.setVehicle(domain.getVehicle());
         if(domain.getCategory_idsDirtyFlag())
            model.setCategory_ids(domain.getCategory_ids());
         if(domain.getShow_leavesDirtyFlag())
            model.setShow_leaves(domain.getShow_leaves());
         if(domain.getCreate_dateDirtyFlag())
            model.setCreate_date(domain.getCreate_date());
         if(domain.getParent_id_textDirtyFlag())
            model.setParent_id_text(domain.getParent_id_text());
         if(domain.getWrite_uid_textDirtyFlag())
            model.setWrite_uid_text(domain.getWrite_uid_text());
         if(domain.getNameDirtyFlag())
            model.setName(domain.getName());
         if(domain.getCreate_uid_textDirtyFlag())
            model.setCreate_uid_text(domain.getCreate_uid_text());
         if(domain.getAddress_home_id_textDirtyFlag())
            model.setAddress_home_id_text(domain.getAddress_home_id_text());
         if(domain.getTzDirtyFlag())
            model.setTz(domain.getTz());
         if(domain.getResource_calendar_id_textDirtyFlag())
            model.setResource_calendar_id_text(domain.getResource_calendar_id_text());
         if(domain.getUser_id_textDirtyFlag())
            model.setUser_id_text(domain.getUser_id_text());
         if(domain.getDepartment_id_textDirtyFlag())
            model.setDepartment_id_text(domain.getDepartment_id_text());
         if(domain.getCountry_of_birth_textDirtyFlag())
            model.setCountry_of_birth_text(domain.getCountry_of_birth_text());
         if(domain.getExpense_manager_id_textDirtyFlag())
            model.setExpense_manager_id_text(domain.getExpense_manager_id_text());
         if(domain.getJob_id_textDirtyFlag())
            model.setJob_id_text(domain.getJob_id_text());
         if(domain.getAddress_id_textDirtyFlag())
            model.setAddress_id_text(domain.getAddress_id_text());
         if(domain.getCompany_id_textDirtyFlag())
            model.setCompany_id_text(domain.getCompany_id_text());
         if(domain.getActiveDirtyFlag())
            model.setActive(domain.getActive());
         if(domain.getCoach_id_textDirtyFlag())
            model.setCoach_id_text(domain.getCoach_id_text());
         if(domain.getCountry_id_textDirtyFlag())
            model.setCountry_id_text(domain.getCountry_id_text());
         if(domain.getAddress_home_idDirtyFlag())
            model.setAddress_home_id(domain.getAddress_home_id());
         if(domain.getExpense_manager_idDirtyFlag())
            model.setExpense_manager_id(domain.getExpense_manager_id());
         if(domain.getBank_account_idDirtyFlag())
            model.setBank_account_id(domain.getBank_account_id());
         if(domain.getWrite_uidDirtyFlag())
            model.setWrite_uid(domain.getWrite_uid());
         if(domain.getCreate_uidDirtyFlag())
            model.setCreate_uid(domain.getCreate_uid());
         if(domain.getCountry_idDirtyFlag())
            model.setCountry_id(domain.getCountry_id());
         if(domain.getCompany_idDirtyFlag())
            model.setCompany_id(domain.getCompany_id());
         if(domain.getJob_idDirtyFlag())
            model.setJob_id(domain.getJob_id());
         if(domain.getResource_idDirtyFlag())
            model.setResource_id(domain.getResource_id());
         if(domain.getUser_idDirtyFlag())
            model.setUser_id(domain.getUser_id());
         if(domain.getDepartment_idDirtyFlag())
            model.setDepartment_id(domain.getDepartment_id());
         if(domain.getParent_idDirtyFlag())
            model.setParent_id(domain.getParent_id());
         if(domain.getLast_attendance_idDirtyFlag())
            model.setLast_attendance_id(domain.getLast_attendance_id());
         if(domain.getCoach_idDirtyFlag())
            model.setCoach_id(domain.getCoach_id());
         if(domain.getAddress_idDirtyFlag())
            model.setAddress_id(domain.getAddress_id());
         if(domain.getCountry_of_birthDirtyFlag())
            model.setCountry_of_birth(domain.getCountry_of_birth());
         if(domain.getResource_calendar_idDirtyFlag())
            model.setResource_calendar_id(domain.getResource_calendar_id());
        return model ;
    }

    public Hr_employee convert2Domain( Ihr_employee model ,Hr_employee domain) {
        if(model == null)
            return domain ;
        if(domain == null){
            domain = new Hr_employee();
        }

        if(model.getMobile_phoneDirtyFlag())
            domain.setMobile_phone(model.getMobile_phone());
        if(model.getMessage_has_error_counterDirtyFlag())
            domain.setMessage_has_error_counter(model.getMessage_has_error_counter());
        if(model.getMessage_needaction_counterDirtyFlag())
            domain.setMessage_needaction_counter(model.getMessage_needaction_counter());
        if(model.getLeave_date_fromDirtyFlag())
            domain.setLeave_date_from(model.getLeave_date_from());
        if(model.getMessage_unreadDirtyFlag())
            domain.setMessage_unread(model.getMessage_unread());
        if(model.getChildrenDirtyFlag())
            domain.setChildren(model.getChildren());
        if(model.getImage_smallDirtyFlag())
            domain.setImage_small(model.getImage_small());
        if(model.getMessage_needactionDirtyFlag())
            domain.setMessage_needaction(model.getMessage_needaction());
        if(model.getPinDirtyFlag())
            domain.setPin(model.getPin());
        if(model.getMessage_main_attachment_idDirtyFlag())
            domain.setMessage_main_attachment_id(model.getMessage_main_attachment_id());
        if(model.getStudy_schoolDirtyFlag())
            domain.setStudy_school(model.getStudy_school());
        if(model.getActivity_idsDirtyFlag())
            domain.setActivity_ids(model.getActivity_ids());
        if(model.getMaritalDirtyFlag())
            domain.setMarital(model.getMarital());
        if(model.getDirect_badge_idsDirtyFlag())
            domain.setDirect_badge_ids(model.getDirect_badge_ids());
        if(model.getImage_mediumDirtyFlag())
            domain.setImage_medium(model.getImage_medium());
        if(model.get__last_updateDirtyFlag())
            domain.set__last_update(model.get__last_update());
        if(model.getEmergency_phoneDirtyFlag())
            domain.setEmergency_phone(model.getEmergency_phone());
        if(model.getActivity_date_deadlineDirtyFlag())
            domain.setActivity_date_deadline(model.getActivity_date_deadline());
        if(model.getKm_home_workDirtyFlag())
            domain.setKm_home_work(model.getKm_home_work());
        if(model.getVisa_noDirtyFlag())
            domain.setVisa_no(model.getVisa_no());
        if(model.getPlace_of_birthDirtyFlag())
            domain.setPlace_of_birth(model.getPlace_of_birth());
        if(model.getSpouse_complete_nameDirtyFlag())
            domain.setSpouse_complete_name(model.getSpouse_complete_name());
        if(model.getSinidDirtyFlag())
            domain.setSinid(model.getSinid());
        if(model.getBadge_idsDirtyFlag())
            domain.setBadge_ids(model.getBadge_ids());
        if(model.getWork_emailDirtyFlag())
            domain.setWork_email(model.getWork_email());
        if(model.getHas_badgesDirtyFlag())
            domain.setHas_badges(model.getHas_badges());
        if(model.getCurrent_leave_idDirtyFlag())
            domain.setCurrent_leave_id(model.getCurrent_leave_id());
        if(model.getContract_idsDirtyFlag())
            domain.setContract_ids(model.getContract_ids());
        if(model.getMessage_is_followerDirtyFlag())
            domain.setMessage_is_follower(model.getMessage_is_follower());
        if(model.getMessage_channel_idsDirtyFlag())
            domain.setMessage_channel_ids(model.getMessage_channel_ids());
        if(model.getBarcodeDirtyFlag())
            domain.setBarcode(model.getBarcode());
        if(model.getBirthdayDirtyFlag())
            domain.setBirthday(model.getBirthday());
        if(model.getCertificateDirtyFlag())
            domain.setCertificate(model.getCertificate());
        if(model.getActivity_user_idDirtyFlag())
            domain.setActivity_user_id(model.getActivity_user_id());
        if(model.getStudy_fieldDirtyFlag())
            domain.setStudy_field(model.getStudy_field());
        if(model.getWebsite_message_idsDirtyFlag())
            domain.setWebsite_message_ids(model.getWebsite_message_ids());
        if(model.getActivity_summaryDirtyFlag())
            domain.setActivity_summary(model.getActivity_summary());
        if(model.getAttendance_stateDirtyFlag())
            domain.setAttendance_state(model.getAttendance_state());
        if(model.getContracts_countDirtyFlag())
            domain.setContracts_count(model.getContracts_count());
        if(model.getGenderDirtyFlag())
            domain.setGender(model.getGender());
        if(model.getImageDirtyFlag())
            domain.setImage(model.getImage());
        if(model.getSpouse_birthdateDirtyFlag())
            domain.setSpouse_birthdate(model.getSpouse_birthdate());
        if(model.getMessage_unread_counterDirtyFlag())
            domain.setMessage_unread_counter(model.getMessage_unread_counter());
        if(model.getLeaves_countDirtyFlag())
            domain.setLeaves_count(model.getLeaves_count());
        if(model.getNotesDirtyFlag())
            domain.setNotes(model.getNotes());
        if(model.getAdditional_noteDirtyFlag())
            domain.setAdditional_note(model.getAdditional_note());
        if(model.getWrite_dateDirtyFlag())
            domain.setWrite_date(model.getWrite_date());
        if(model.getMedic_examDirtyFlag())
            domain.setMedic_exam(model.getMedic_exam());
        if(model.getVisa_expireDirtyFlag())
            domain.setVisa_expire(model.getVisa_expire());
        if(model.getWork_phoneDirtyFlag())
            domain.setWork_phone(model.getWork_phone());
        if(model.getEmergency_contactDirtyFlag())
            domain.setEmergency_contact(model.getEmergency_contact());
        if(model.getNewly_hired_employeeDirtyFlag())
            domain.setNewly_hired_employee(model.getNewly_hired_employee());
        if(model.getDisplay_nameDirtyFlag())
            domain.setDisplay_name(model.getDisplay_name());
        if(model.getIs_address_home_a_companyDirtyFlag())
            domain.setIs_address_home_a_company(model.getIs_address_home_a_company());
        if(model.getAttendance_idsDirtyFlag())
            domain.setAttendance_ids(model.getAttendance_ids());
        if(model.getActivity_stateDirtyFlag())
            domain.setActivity_state(model.getActivity_state());
        if(model.getMessage_has_errorDirtyFlag())
            domain.setMessage_has_error(model.getMessage_has_error());
        if(model.getCurrent_leave_stateDirtyFlag())
            domain.setCurrent_leave_state(model.getCurrent_leave_state());
        if(model.getChild_idsDirtyFlag())
            domain.setChild_ids(model.getChild_ids());
        if(model.getMessage_idsDirtyFlag())
            domain.setMessage_ids(model.getMessage_ids());
        if(model.getColorDirtyFlag())
            domain.setColor(model.getColor());
        if(model.getManual_attendanceDirtyFlag())
            domain.setManual_attendance(model.getManual_attendance());
        if(model.getRemaining_leavesDirtyFlag())
            domain.setRemaining_leaves(model.getRemaining_leaves());
        if(model.getSsnidDirtyFlag())
            domain.setSsnid(model.getSsnid());
        if(model.getJob_titleDirtyFlag())
            domain.setJob_title(model.getJob_title());
        if(model.getActivity_type_idDirtyFlag())
            domain.setActivity_type_id(model.getActivity_type_id());
        if(model.getIs_absent_totayDirtyFlag())
            domain.setIs_absent_totay(model.getIs_absent_totay());
        if(model.getMessage_partner_idsDirtyFlag())
            domain.setMessage_partner_ids(model.getMessage_partner_ids());
        if(model.getPassport_idDirtyFlag())
            domain.setPassport_id(model.getPassport_id());
        if(model.getGoal_idsDirtyFlag())
            domain.setGoal_ids(model.getGoal_ids());
        if(model.getLeave_date_toDirtyFlag())
            domain.setLeave_date_to(model.getLeave_date_to());
        if(model.getManagerDirtyFlag())
            domain.setManager(model.getManager());
        if(model.getWork_locationDirtyFlag())
            domain.setWork_location(model.getWork_location());
        if(model.getMessage_attachment_countDirtyFlag())
            domain.setMessage_attachment_count(model.getMessage_attachment_count());
        if(model.getContract_idDirtyFlag())
            domain.setContract_id(model.getContract_id());
        if(model.getGoogle_drive_linkDirtyFlag())
            domain.setGoogle_drive_link(model.getGoogle_drive_link());
        if(model.getPermit_noDirtyFlag())
            domain.setPermit_no(model.getPermit_no());
        if(model.getMessage_follower_idsDirtyFlag())
            domain.setMessage_follower_ids(model.getMessage_follower_ids());
        if(model.getIdDirtyFlag())
            domain.setId(model.getId());
        if(model.getIdentification_idDirtyFlag())
            domain.setIdentification_id(model.getIdentification_id());
        if(model.getVehicleDirtyFlag())
            domain.setVehicle(model.getVehicle());
        if(model.getCategory_idsDirtyFlag())
            domain.setCategory_ids(model.getCategory_ids());
        if(model.getShow_leavesDirtyFlag())
            domain.setShow_leaves(model.getShow_leaves());
        if(model.getCreate_dateDirtyFlag())
            domain.setCreate_date(model.getCreate_date());
        if(model.getParent_id_textDirtyFlag())
            domain.setParent_id_text(model.getParent_id_text());
        if(model.getWrite_uid_textDirtyFlag())
            domain.setWrite_uid_text(model.getWrite_uid_text());
        if(model.getNameDirtyFlag())
            domain.setName(model.getName());
        if(model.getCreate_uid_textDirtyFlag())
            domain.setCreate_uid_text(model.getCreate_uid_text());
        if(model.getAddress_home_id_textDirtyFlag())
            domain.setAddress_home_id_text(model.getAddress_home_id_text());
        if(model.getTzDirtyFlag())
            domain.setTz(model.getTz());
        if(model.getResource_calendar_id_textDirtyFlag())
            domain.setResource_calendar_id_text(model.getResource_calendar_id_text());
        if(model.getUser_id_textDirtyFlag())
            domain.setUser_id_text(model.getUser_id_text());
        if(model.getDepartment_id_textDirtyFlag())
            domain.setDepartment_id_text(model.getDepartment_id_text());
        if(model.getCountry_of_birth_textDirtyFlag())
            domain.setCountry_of_birth_text(model.getCountry_of_birth_text());
        if(model.getExpense_manager_id_textDirtyFlag())
            domain.setExpense_manager_id_text(model.getExpense_manager_id_text());
        if(model.getJob_id_textDirtyFlag())
            domain.setJob_id_text(model.getJob_id_text());
        if(model.getAddress_id_textDirtyFlag())
            domain.setAddress_id_text(model.getAddress_id_text());
        if(model.getCompany_id_textDirtyFlag())
            domain.setCompany_id_text(model.getCompany_id_text());
        if(model.getActiveDirtyFlag())
            domain.setActive(model.getActive());
        if(model.getCoach_id_textDirtyFlag())
            domain.setCoach_id_text(model.getCoach_id_text());
        if(model.getCountry_id_textDirtyFlag())
            domain.setCountry_id_text(model.getCountry_id_text());
        if(model.getAddress_home_idDirtyFlag())
            domain.setAddress_home_id(model.getAddress_home_id());
        if(model.getExpense_manager_idDirtyFlag())
            domain.setExpense_manager_id(model.getExpense_manager_id());
        if(model.getBank_account_idDirtyFlag())
            domain.setBank_account_id(model.getBank_account_id());
        if(model.getWrite_uidDirtyFlag())
            domain.setWrite_uid(model.getWrite_uid());
        if(model.getCreate_uidDirtyFlag())
            domain.setCreate_uid(model.getCreate_uid());
        if(model.getCountry_idDirtyFlag())
            domain.setCountry_id(model.getCountry_id());
        if(model.getCompany_idDirtyFlag())
            domain.setCompany_id(model.getCompany_id());
        if(model.getJob_idDirtyFlag())
            domain.setJob_id(model.getJob_id());
        if(model.getResource_idDirtyFlag())
            domain.setResource_id(model.getResource_id());
        if(model.getUser_idDirtyFlag())
            domain.setUser_id(model.getUser_id());
        if(model.getDepartment_idDirtyFlag())
            domain.setDepartment_id(model.getDepartment_id());
        if(model.getParent_idDirtyFlag())
            domain.setParent_id(model.getParent_id());
        if(model.getLast_attendance_idDirtyFlag())
            domain.setLast_attendance_id(model.getLast_attendance_id());
        if(model.getCoach_idDirtyFlag())
            domain.setCoach_id(model.getCoach_id());
        if(model.getAddress_idDirtyFlag())
            domain.setAddress_id(model.getAddress_id());
        if(model.getCountry_of_birthDirtyFlag())
            domain.setCountry_of_birth(model.getCountry_of_birth());
        if(model.getResource_calendar_idDirtyFlag())
            domain.setResource_calendar_id(model.getResource_calendar_id());
        return domain ;
    }


}
